$(window).load(function() {
    resizeFontSize();
    $( window ).resize(resizeFontSize);
});

function resizeFontSize(){
    var preferredWidth = 1100;
    var displayWidth = $(window).width();
    if(isMobile.any() || displayWidth <767){
        preferredWidth=resizeSmartphone();
    }
    else if(isTablet.any() || (displayWidth<1024 && displayWidth>=767)){
        preferredWidth=resizeTablet();
    }
    if(displayWidth>preferredWidth){
        var percentage = displayWidth / preferredWidth;
        var newFontSize = Math.floor(16 * percentage) - 1;
        $("body").css("font-size", newFontSize);
    }
    
}


function resizeTablet(){
    return 768;
}

function resizeSmartphone(){
    return 480;
}


var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};

var isTablet = {
    any: function() {
        return navigator.userAgent.match(/iPad/);
    }
};

$('.disableButton').click(function() {
    $(this)[0].setAttribute('disabled','disabled');
    $(this).addClass('ui-state-disabled');
});